#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
@Author   : 李吉凯
@Email    : lijikai1206@163.com
@Time     : 2021/5/26 6:58
@File     : Test_TouchAction.py
'''
from time import sleep
from selenium import webdriver
from selenium.webdriver import TouchActions


class TestActionChains():
    def setup(self):
        option = webdriver.ChromeOptions()
        option.add_experimental_option('w3c', False)
        self.driver = webdriver.Chrome(options=option)
        self.driver.implicitly_wait(5)

    def teardown(self):
        self.driver.quit()

    def test_touchaction_scrollbottom(self):
        self.driver.get("http://www.baidu.com")
        ele = self.driver.find_element_by_id('kw')
        ele_search = self.driver.find_element_by_id('su')

        ele.send_keys("selenium测试")
        action = TouchActions(self.driver)
        action.tap(ele_search)
        action.perform()

        action.scroll_from_element(ele, 0, 1500).perform()
        sleep(3)


